package com.ruike.alisurface.project_DaTi;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ruike.alisurface.R;
import com.ruike.alisurface.Serials.MsgEventBus;
import com.ruike.alisurface.base.BaseAty;
import com.ruike.alisurface.project_DaTi.bean.QuestionCarGoodsBean;
import com.ruike.alisurface.utils.ShareKey;
import com.voodoo.lib_utils.ShareUtils;
import com.voodoo.lib_utils.imageLoader.ImageLoader;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author: voodoo
 * CreateDate: 2020/07/21 021 05:25 下午
 * Description: 答题确认
 */
public class AnswerConfirmActivity extends BaseAty {

    @BindView(R.id.answerConfirm_goodsImg_imgv)
    ImageView goodsImgImgv;
    @BindView(R.id.answerConfirm_goodsName_tv)
    TextView goodsNameTv;
    @BindView(R.id.answerConfirm_require_tv)
    TextView requireTv;
    QuestionCarGoodsBean carGoodsBean;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_answer_confirm;
    }

    @Override
    protected void initViews() {
        initTitleBar(false);
        startCountdownTimer(60, null, null);
    }

    @Override
    protected void initData() {
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            carGoodsBean = (QuestionCarGoodsBean) bundle.getSerializable("product");
        }

        if (carGoodsBean != null) {
            ShareUtils.getInstance().putString(ShareKey.STRATEGY_ID, carGoodsBean.getStrategy_id());
            ImageLoader.loadImage(this, carGoodsBean.getProduct_pic(), goodsImgImgv);
            goodsNameTv.setText(carGoodsBean.getProduct_name());
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("本商品共答 ");
            stringBuffer.append(carGoodsBean.getSet_question_count());
            stringBuffer.append(" 题\n最少必须答对 ");
            stringBuffer.append(carGoodsBean.getSet_pass_count());
            stringBuffer.append(" 题");
            requireTv.setText(stringBuffer.toString()); // 本商品共答 4 题 \n 最少必须答对 1 题
        }
    }

    @Override
    public void doEventBusResult(MsgEventBus event) {

    }

    @OnClick({R.id.answerConfirm_goback_imgv, R.id.answerConfirm_goAnswer_tv})
    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.answerConfirm_goback_imgv:
                startCountdownTimer(0, null, null);
                break;
            case R.id.answerConfirm_goAnswer_tv:
                startActivity(AnswerQuestionActivity.class, null);
                finish();
                break;
        }
    }

}
